<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script>
       window.onload = function(){
           function $(id){
               return document.getElementById(id);
           }
           $("btn").onclick = function(){
               //alert(11);
               //alert($("txt").value); // 获得表单的值
               if($("txt").value == "刘德华")
               {
                   alert("恭喜");
               }
               else
               {
                   alert("查无此人");
               }
           }
       }
    </script>
</head>
<body>
<input type="text" id="txt" value="请输入.."/> <button id="btn">查询</button>
</body>
</html>